package com.hospital.demo.service.impl.gaoyuran;

import com.hospital.demo.enums.ExceptionCodeEnums;
import com.hospital.demo.exception.HospitalException;
import com.hospital.demo.mapper.gaoyuran.ExperimentMapper;
import com.hospital.demo.model.gaoyuran.Experiment;
import com.hospital.demo.service.gaoyuran.ExperimentSer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ExperimentImpl implements ExperimentSer {


    @Autowired
    private ExperimentMapper experimentMapper;

    @Autowired
    private ExperimentSer experimentSer;

    //查看全部临床实验信息
    @Override
    public List<Experiment> findAllExperiment() {
        return experimentMapper.findAllExperiment();
    }

    //更新临床实验信息
    @Override
    public int upDateExperiment(Experiment experiment) {
        try {
            experimentMapper.updateByPrimaryKey(experiment);
        } catch (Exception e) {
            throw new HospitalException(ExceptionCodeEnums.UPDATE_FAIL);
        }
        return 0;
    }

    //临床实验信息录入
    @Override
    public int AddExperiment(Experiment experiment) {
        try {
            experimentMapper.insert(experiment);
        } catch (Exception e) {
            throw new HospitalException(ExceptionCodeEnums.INSERT_FAIL);
        }
        return 0;
    }
}
